//
//  SDBaseData.h
//  SKinDiary
//
//  Created by pcyang on 16/6/26.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import <Foundation/Foundation.h>


typedef NS_ENUM(NSUInteger,SDLoadPageType)
{
    SDLoadPageTypeRefresh,
    SDLoadPageTypePullUp,
    SDLoadPageTypePullDown,
};

typedef NS_ENUM(NSUInteger, SDBaseDataType)
{
    SDBaseDataTypeNone,
    SDBaseDataTypeCache,
    SDBaseDataTypeRefresh,
    SDBaseDataTypeUpdate,
};

@class SDBaseData;
@protocol SDBaseDataDelegate <NSObject>
@optional
- (void)dataWillStartLoad:(SDBaseData*)model;
- (void)data:(SDBaseData*)model didFinishLoadWithError:(NSError*)error nextDataType:(SDBaseDataType)nextDataType;
@end

@interface SDBaseData : NSObject

@property (nonatomic,strong)NSDate*       lastUpdateTime;
@property (nonatomic,strong)   id       modelData;
@property (nonatomic,assign)SDBaseDataType dataType;
@property (nonatomic,assign)SDLoadPageType loadPageType;
@property (nonatomic,weak)id <SDBaseDataDelegate>       delegate;

- (BOOL)isLoading;

-(NSString*)getRequestUrl;
- (id)resetWithResponseModel:(id)data;

- (void)reloadDataWithCache:(BOOL)readCache;
- (void)refreshData;
-(void)pullDownLoadData;    //下拉
- (void)loadMoreData;       //上拉

- (void)cancelRequest;
- (void)clearDelegatesAndCancel;

- (BOOL)hasLocalCacheFile;

@end
